package com.mm.controller.other;

import com.github.AopLog;
import com.mm.util.result.DResult;
import com.mm.domain.other.*;
import com.mm.serivce.common.ThirdPartyService;
import com.mm.vo.mp.PayOrderReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 描述: 第三方接口调用
 *
 * @author: yanglin
 * @Date: 2022-01-21-15:54
 * @Version: 1.0
 */
@Api(value = "/th/v1", tags = {"第三方接口调用"})
@Slf4j
@RestController
@RequestMapping("/th/v1")
@AopLog(type = "第三方接口", stackTraceOnErr = true)
public class ThirdPartyController {

    @Autowired
    private ThirdPartyService thirdPartyService;

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "string", dataTypeClass = String.class, name = "cityName", value = ""),
            @ApiImplicitParam(paramType = "query", dataType = "int", dataTypeClass = Integer.class, name = "type", value = "")
    })
    @ApiOperation(value = "天气查询接口", notes = "", httpMethod = "POST")
    @PostMapping("/queryWeatherInfo")
    public DResult queryWeatherInfo(@RequestParam @ApiParam(name = "cityName", value = "城市名") String cityName,
                                    @RequestParam(required = false) @ApiParam(name = "type", value = "类型(1.当天 2.未来7天 3.未来8-15天)") Integer type) {
        List<WeatherInfo> weatherInfos = thirdPartyService.queryWeatherInfo(cityName, type);
        return DResult.of(weatherInfos);
    }

    /**
     * epidemicRiskLevel(高危等级地区)
     * epidemicInfectionData(疫情数据)
     * epidemicHotspot(疫情热点)
     * @param type
     * @return
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "string", dataTypeClass = String.class, name = "type", value = "")
    })
    @ApiOperation(value = "疫情信息查询接口", notes = "epidemicRiskLevel(高危等级地区) epidemicInfectionData(疫情数据) epidemicHotspot(疫情热点)", httpMethod = "POST")
    @PostMapping("/queryEpidemic")
    public DResult queryEpidemic(@RequestParam(required = false) @ApiParam(name = "type", value = "类型，可选[epidemicRiskLevel(高危等级地区)，epidemicHotspot(疫情热点)]") String type) {
        List<Epidemic> epidemic = thirdPartyService.queryEpidemic(type);
        return DResult.of(epidemic);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "string", dataTypeClass = String.class, name = "express", value = "")
    })
    @ApiOperation(value = "快递信息查询接口(IP限制不可用)", notes = "", httpMethod = "POST")
    @PostMapping("/queryExpressInfo")
    public DResult queryExpressInfo(@RequestParam @ApiParam(name = "express", value = "快递单号") String express) {
        ExpressInfo expressInfo = thirdPartyService.queryExpressInfo(express);
        return DResult.of(expressInfo);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "string", dataTypeClass = String.class, name = "phone", value = "")
    })
    @ApiOperation(value = "手机号归属地查询接口", notes = "", httpMethod = "POST")
    @PostMapping("/queryMobileAddress")
    public DResult queryMobileAddress(@RequestParam @ApiParam(name = "phone", value = "手机号") String phone) {
        MobileAddress mobileAddress = thirdPartyService.queryMobileAddress(phone);
        return DResult.of(mobileAddress);
    }
}
